﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq;

namespace DAL
{
    /// <summary>
    /// 数据上下文分部类扩展
    /// </summary>
    public partial class TestDataContext : IUnitOfWork
    {

        partial void OnCreated()
        {
            DataLoadOptions dl = new DataLoadOptions();
            this.DeferredLoadingEnabled = false;//关闭延时加载,对于列表访问时，性能不加,默认为true，开启延时加载
            #region 优化后的延时加载，对某个对象进行立即加载
            dl.LoadWith<Order_Info>(p => p.Order_Detail);
            dl.LoadWith<Product>(p => p.ProductDetail);
            dl.AssociateWith<Product>(p => p.ProductDetail.Where(i => i.Info != null));//全局过滤集合
            this.LoadOptions = dl;
            #endregion

        }
        #region IUnitOfWork 成员

        public void SaveChanges()
        {
            this.SubmitChanges();
        }

        public bool IsNotSubmit { get; set; }

        #endregion
    }
}